package com.springcloud.eureka;

import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@EnableApolloConfig
@Slf4j
@EnableEurekaServer
@SpringBootApplication
public class EurekaApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaApplication.class, args);
        log.info("\n--START-UP SUCCESS \n" +
                "--┌─┐┬ ┬┌─┐┌─┐┌─┐┌─┐┌─┐\n" +
                "--└─┐│ ││  │  ├┤ └─┐└─┐\n" +
                "--└─┘└─┘└─┘└─┘└─┘└─┘└─┘\n");
    }
    /*
       第一种方式 配置Eureka用户认证
     * 高版本的丢弃了
     * security:
     *   basic:
     *    enabled: true
     * 新版的security默认启用了csrf检验，如果不关闭该检验，eureka client端向eureka server注册时，
     * 会报如下异常：com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server，
     * eureka client注册服务时如何避免该异常，考虑先关闭csrf检验：
     * */
    /*@EnableWebSecurity
    static class WebSecurityConfig extends WebSecurityConfigurerAdapter {
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.csrf().ignoringAntMatchers("/eureka/**");
            super.configure(http);
        }
    }*/
}
